/**
 * 办事大厅
 */
 var json=[
	             {
	                 "RowNum": 8,
	                 "ConsumeAmount": 30,
	                 "CardValue": 268.1,
	                 "ConsumeDate": "2017-01-11 18:07:52",
	                 "ShopName": "成都冒菜",
	                 "ConsumeType": "消费"
	             },
	             {
	                 "RowNum": 9,
	                 "ConsumeAmount": 8.5,
	                 "CardValue": 298.1,
	                 "ConsumeDate": "2017-01-11 08:35:25",
	                 "ShopName": "快乐时间#沁园",
	                 "ConsumeType": "消费"
	             },
	             {
	                 "RowNum": 10,
	                 "ConsumeAmount": 3,
	                 "CardValue": 306.6,
	                 "ConsumeDate": "2017-01-11 08:34:33",
	                 "ShopName": "快乐食间#大吧豆浆",
	                 "ConsumeType": "消费"
	             },
	             {
	                 "RowNum": 11,
	                 "ConsumeAmount": 18,
	                 "CardValue": 309.6,
	                 "ConsumeDate": "2017-01-10 12:10:12",
	                 "ShopName": "老麻抄手",
	                 "ConsumeType": "消费"
	             },
	             {
	                 "RowNum": 12,
	                 "ConsumeAmount": 8.5,
	                 "CardValue": 327.6,
	                 "ConsumeDate": "2017-01-10 08:39:02",
	                 "ShopName": "快乐时间#沁园",
	                 "ConsumeType": "消费"
	             },
	             {
	                 "RowNum": 13,
	                 "ConsumeAmount": 3,
	                 "CardValue": 336.1,
	                 "ConsumeDate": "2017-01-10 08:37:38",
	                 "ShopName": "快乐食间#乐吧",
	                 "ConsumeType": "消费"
	             },
	             {
	                 "RowNum": 14,
	                 "ConsumeAmount": 10,
	                 "CardValue": 339.1,
	                 "ConsumeDate": "2017-01-05 18:06:53",
	                 "ShopName": "老麻抄手",
	                 "ConsumeType": "消费"
	             },
	             {
	                 "RowNum": 15,
	                 "ConsumeAmount": 6,
	                 "CardValue": 349.1,
	                 "ConsumeDate": "2017-01-03 12:56:16",
	                 "ShopName": "雅林超市",
	                 "ConsumeType": "消费"
	             }
	         ];
	   paint_function();
	   $('button#search_function').click(function(){
		     var search=$(this).prev().val();
		     if(search.length!=0){
		    	 $('ul.functions_target').next().empty();
		         $.getJSON('/WDDXSERVER/bsdt/SearchFunctionListFromBSDT?callback=?',{userid:user_id,function_name:encodeURI(search),ticket:ticket},function(Data){
		        	  for(var i=0;i<Data.length;i++)
		        		  function_detials(Data[i]);        	    
		        });
		    }
	   });
	   $('button#search_back').click(function(){
		   $(this).prevAll('input').val('');
		   $('ul.functions_target').empty().next().empty();
		   paint_function();
	   });
	  
	 //绑定评分星星点击切换状态事件
	   var fs;
	   $('.reveal-modal-footer ul li:not(".fabulous")').unbind().click(function(){
		  var _this = $(this);
		  var doms = $('.reveal-modal-footer ul li:not(".fabulous")');
		  if(_this.hasClass("spanActive")){
			  var index ="";
			  $.each(doms,function(i,rec){
				  if(rec==_this[0]){
					 index = i;
					 fs=i-1;
					 $(rec).removeClass("spanActive");
				  }
				  if(i>index && index!=""){
					 $(rec).removeClass("spanActive");
				  }
			  });
		  }else{
			  $.each(doms,function(i,rec){
				  $(rec).addClass("spanActive");
				  fs=i;
				  if(rec==_this[0]){
					  return false;
				  }
			  });
		  }
	   });
	   //绑定点赞点击事件
	   $('.reveal-modal-footer ul li.dz').click(function(){
		  var _this = $(this);
		  _this.children("a").children("span").toggleClass("spanfabulous");
		  $.ajaxSettings.async=false;
			$.getJSON('/WDDXSERVER/bsdt/functionDz.action?userid='+user_id+'&ticket='+ticket,
				  {
					function_id:function_id
				  },
				  function(data){
				  });
	   });
	   //绑定提交事件
	   $('.reveal-modal-footer ul li.submit').click(function(){
			$.ajaxSettings.async=false;
			$.getJSON('/WDDXSERVER/bsdt/functionPf.action?userid='+user_id+'&ticket='+ticket,
				  {
					function_id:function_id,
			 		fs:fs
				  },
				  function(data){
				  });
	   });
	   $('a.close-reveal-modal').bind('click',function(){
			 $('a.back-reveal-modal').hide(0);
			 $('div.content').empty();
			 $('h3.reveal-modal-header').empty();
		 });
	   $('#the_table').bootstrapTable({
		//	url : data,
		    data:json,
			columns :  [
	                    {
	                        field: 'ConsumeAmount',
	                        title: '消费金额',
	                        align: 'center',
	                        valign: 'middle'
	                    }, {
	                        title: '余额',
	                        field: 'CardValue',
	                        align: 'center',
	                        valign: 'middle'
	                    }, {
	                        title: '消费日期',
	                        field:'ConsumeDate',
	                        valign: 'middle',
	                        align: 'center'
	                    },
	                    {
	                        title: '消费地点',
	                        field:'ShopName',
	                        valign: 'middle',
	                        align: 'center'
	                    }
	                ],
		//	sidePagination : 'server',
	    	sidePagination : 'client',
			pagination : 'true',
			pageSize : 6,
			search : false,
			searchOnEnterKey : true,
			locale : 'zh-CN'
		});		
	   $('ul.content_info_explain a').click(function(){
		  $(this).next('div').toggle('slow');
		  return false; 
	   });
	   //拖动
	   var isMove = true;
	   $('#myModal h3').mousedown(function(event){
		   event.preventDefault();
		   isMove = true;
		   var abs_x = event.pageX - $('div#myModal').offset().left;
		   var abs_y = event.pageY - $('div#myModal').offset().top;
		   var divwidth = $('#myModal').width()/2;
		   var divheitht = $('#myModal').height();
		   var screenheight =  $(document).height();
		   var screenwidth = $(document).width();
		   $(document).mousemove(function(event){
				  if(isMove){
					  var obj = $('div#myModal');
					  if(event.pageX-abs_x>=0&&event.pageY-abs_y>=0&&event.pageX-abs_x+divwidth*2<=screenwidth&&event.pageY-abs_y+divheitht<screenheight){
					  	  obj.css({'left':event.pageX - abs_x + divwidth,'top':event.pageY - abs_y +divheitht/2});
					  }
				   } 
		   }).mouseup(function(){
				   isMove = false;
		   });
	   });
//创建应用类型列表
 function paint_function(){
		   $.getJSON('/WDDXSERVER/bsdt/getFunctionListFromBSDT?callback=?',{userid:user_id,ticket:ticket},function(Data){
			   var $node= $('ul.functions_target');
			   var length=Data.length;
			   for(var i=0;i<length;i++){
				   $node.append('<li ><a href="#fun_type'+Data[i].lb+'"><img src="'+Data[i].pic+'" />'+Data[i].name_zhcn+'</a></li>');
				   function_detials(Data[i]);
				}

			});
	   }
 //创建应用类型下面的功能列表
 function  function_detials(Data){
		   var the_str=[];
		   var the_length=Data.data.length;
		   var dz;
		   for(var j=0;j<the_length;j++){
			  dz= Data.data[j].dz;
			    the_str[j] = '<li id="fun_type'+Data.lb+'">'
						+ '<a href="javascript:;" function="'+Data.data[j].function_id+'" path="'+Data.data[j].function_path+"?function_id="+Data.data[j].function_id+'"'
						+'class="big-link" data-reveal-id="myModal" data-animation="none">'
						+ '<img src="'+Data.data[j].pic+'" />'
						+ '<div class="function_describe">' 
						+ '<span>'+Data.data[j].function_name + '</span>'
						+ '<span><span style="width:'+ parseInt(Data.data[j].pf) * 20+ '%"></span></span>'
//						+ '<span class="dz'+dz+'"> '+ Data.data[j].dz + '</span>' 
						+ '<span class="dz'+dz+'"></span>' 
						+ '</div>'
						+'<div class="clear"></div>'
						+ '</a>' + '</li>';
			}
		   $('ul.functions_target').next('ul').append('<li class="functions_shadow" ><h4 class="function_title">'+Data.name_zhcn+' | '+Data.name_en +'</h4><ul class="functions_detials">'+the_str.join('')+'</ul></li>');
		   a_click();
	   }
var function_id='';
 function a_click(){
		   $('ul.functions_detials a').unbind('click').click(function(){
			     var modalLocation = $(this).attr('data-reveal-id');
			     $('#'+modalLocation).reveal($(this).data());
			     var url = $(this).attr("path");
			     function_id= $(this).attr("function");
			     $.ajax({
			    	url:url,
			    	type:'get',
			    	data:{
			    		userid:user_id,
			    		ticket:ticket,
			    	},
			    	dataType:'json',
			    	success:function(data){
			    	
			    		var obj={};
			    			obj.title=data["content"].message.title;
				    		obj.content = createContent(data["content"].message.method,data);
				    		obj.method = data["content"].message.method;
			    		$('#'+modalLocation).office_modal(obj);
//						$('#'+modalLocation).reveal($(this).data());
			    		}
			     });
				
		   });
	   }
 function createContent(func,data){
	 return window["create"+func](data);  //将字符串当成函数执行
 }
 
 //一卡通
 function createYKT(data){
	 var html = '<div class="labels_show">'
		 +'<p>'+"一卡通余额"+data["content"].message.items[0].BALANCE+"元"+'</p>'
		 +'<input type="text" class="starttime">至<input type="text" class="endtime"><button type="button" class="search_mxcx">明细查询</button>'
		 +'</div>'
		 +'<div class="content_info ">'
		 +'<table class="ykt_xfjl">'
		 +'</table>'
		 +'<div class="pagechange"><ul><li>'
		 	+'<li class="nextpage"><a href="javascript:;">下一页></a></li>'
		 	+'<li class="index"><a href="javascript:;">首页</a></li>'
			+'<li class="previouspage"><a href="javascript:;"><上一页</a></li>'
	 		+'</ul></div>'
	 	 +'</div>';
   return html;
 }
 
 //图书借阅
 function createlibrary(data){
	 var html ='<table class="office_library_table">'
		 		    +'<tr>'
		 		      +'<th>'+"图书名称"+'</th>'
		 		      +'<th>'+"图书编号"+'</th>'
		 		      +'<th>'+"借书时间"+'</th>'
		 		      +'<th>'+"还书时间"+'</th>'
//		 		      +'<th>'+"续借次数"+'</th>'
		 		    +'</tr>';
	 if(!(data["content"].message.items==0||data["content"].message.items==null)){
		 $.each(data["content"].message.items,function(i,rec){
			  html +='<tr>'
			            +'<td>'+rec["title"]+'</td>'
	 		            +'<td>'+rec["book_barcode"]+'</td>'
	 		            +'<td>'+rec["date_due"]+'</td>'
	 		            +'<td>'+rec["date_checkout"]+'</td>'
	// 		            +'<td>'+rec["Renew"]+'</td>'
	 		          +'</tr>';
		 });
	 }
	html += '</table>';	 
	return html;
 }
 //通讯录
 function createOffPhone(data){
	 var html = '<div class="office_phone_bm">'
	               +'<ul>';
	 var pid = [];
	 if(!(data["content"].message.items==0||data["content"].message.items==null)){
		 $.each(data["content"].message.bmlist,function(i,rec){ 
			 pid.push(rec["txl_id"]);
			 if(i == 0){
				 html += '<li class="active">'+'<a href="javascript:;" path="txl'+rec["txl_id"]+'" class="'+rec["txl_id"]+'">'+rec["txl_name"]+'</a>'+'</li>';
			 }else{
				 html += '<li>'+'<a href="javascript:;" path="txl'+rec["txl_id"]+'" class="'+rec["txl_id"]+'">'+rec["txl_name"]+'</a>'+'</li>';
			 }
		 });
	 }
	 html+='<div class="clear"></div></ul>' 
		 //+ '<input type="text" class="searchText"><span class="search">'+"查询"+'</span>' 
		 + '</div>';
//	 var html1 ="";
	 var num = 1;
	 var list=[];
	 $.each(pid,function(i,r){
		 var pids = [];
		 var divclass="";
		 list=[];
		 if(i==0){
			  divclass="office_phone_block";
		 }else{
			  divclass="office_phone_none";
		 }
		 html+='<div class="'+divclass+' pr2e pl2e pb1e" id="txl'+r+'" class="pl2e pr2e">';
		 pids.push(r);
		 callbackbm(pids,num);
		 $.each(list,function(i,r){
			   html+=r.html+'</div>'+'</div>';
			 });
		 html+='</div>';
	 });
//	 callbackbm(pid,num);
	 function callbackbm(arr,num){
		 var pid1=[];
		 if(num==1){ //第一次循环  标题
			 $.each(data["content"].message.items,function(i,rec){
				 var obj={};
				 if($.inArray(rec["txl_pid"], arr)>=0){
					if($.inArray(rec["txl_pid"],pid1)<0){
						 pid1.push(rec["txl_id"]);
						 obj.html='<div class="txltitle">'
						                  +'<div class="title">'
              						         +'<a>'
              						            + rec["txl_name"]  
   								             +'</a>' 
              						      +'</div>'
								       + '<div>';
						 obj.id=rec["txl_id"];
						 list.push(obj);
				 }
				 }
			 });
		 }else{//二次以上循环  正文
			 $.each(data["content"].message.items,function(i,rec){
				 if($.inArray(rec["txl_pid"], arr)>=0){
					if($.inArray(rec["txl_pid"],pid1)<0){
						 pid1.push(rec["txl_id"]);
						 $.each(list,function(index,r){
							 if(rec["txl_pid"]==r.id){
								list[index].html+=    '<span>'
									                     +'<a>'
                									        + rec["txl_name"]
								                         +'</a>'
								                         +'<a href="javascript:;">'
								                            + rec["txl_zjhm"]
								                         +'</a>'
										              +'</span>';
							 }
						 });
					 }
				 }
			 });
		 }
		 if(pid1.length==0){
			 return false;//当没有子节点的时候跳出递归
		 }else{
			 ++num;
			 callbackbm(pid1);
		 }
	 }
	
	 return html/*+html1*/;
 }
 //教室查询
 function createclassRoom(data){
	 var html = '<div class="office_select xq">'
                     +'<p>'+"选择校区"+'</p>'
                 +'<select>';
	 if(!(data["content"].message.items==0||data["content"].message.items==null)){
		 $.each(data["content"].message.items,function(i,r){
			 html += '<option value="'+r["XQDM"]+'">'+r["XQMC"]+'</option>';
		 });
	 }
	 html += '</select></div>';
	 var html1 ='<div class="office_select classjc">'
		            +'<p>'+"选择上课节次"+'</p>'
		            +'<select>'
		                +'<option>'+1+'</option>'
		                +'<option>'+2+'</option>'
		                +'<option>'+3+'</option>'
		                +'<option>'+4+'</option>'
		                +'<option>'+5+'</option>'
		                +'<option>'+6+'</option>'
		                +'<option>'+7+'</option>'
		                +'<option>'+8+'</option>'
		                +'<option>'+9+'</option>'
		                +'<option>'+10+'</option>'
		                +'<option>'+11+'</option>'
		                +'<option>'+12+'</option>'
		            +'</select>'
		        +'</div>';
	 var htmlbtn = '<div class="office_select office_btn" style="text-align:center;"><a href="javascript:;">查询</a></div>';
	 var html2 = '<div  class="office_select jxl"><p>选择教学楼</p><select>';
	 var _xq=data["content"].message.items[0].XQDM;
	 $.ajaxSettings.async = false;
	 $.getJSON("/WDDXSERVER/bsdt/jscxlh.action?userid="+user_id+"&ticket="+ticket, 
	 		{ xq: _xq,
			 function_id:function_id
			 },
	 		function(data) { 
				 if(!(data.content.message.items==0||data.content.message.items==null)){
			 		$.each(data.content.message.items,function(i,r){
			 			html2+='<option>'+r["LH"]+'</option>';
					 }); 
				 }
	 });
	 html2+='</select></div>';
	 html += html2+html1+htmlbtn;
//	 html += html1+htmlbtn;
	 return html;
 }
 //班车查询
 function createOffBus(data){
	 var html="";
	 if(data["content"].message.content[0].article_clob){
		 html=data["content"].message.content[0].article_clob;
	 }else{
		 html="there has no data";
	 }
	 return html;
 }
 //成绩查询
 function createOffScore(data){
//	 var json={};
	 var html = '<div class="office_cjcx"><select id="xq">';
	 var html2="";
	 var _rm_xq = data["content"].message.items[0].rm_xq;
	 if(!(data["content"].message.items==0||data["content"].message.items==null)){
		 $.each(data["content"].message.items,function(i,r){
		 	 html+='<option value="'+r.rm_xq+'">'+r.xnxq+'</option>';
		 });
	 }
	 html+= '</select><table><tr>'
		        +'<th>'+"课程名称"+'</th>'
		        +'<th>'+"学分"+'</th>'
		        +'<th>'+"课程性质"+'</th>'
		        +'<th>'+"成绩"+'</th>'
		     +'</tr>';
	 $.ajaxSettings.async = false;
	 $.getJSON("/WDDXSERVER/home/getCJForPc.action?userid="+user_id+"&ticket="+ticket, 
	 		{ rm_xq: _rm_xq },
	 		function(data) { 
	 			if(!(data[0].content.message.items==0||data[0].content.message.items==null)){
			 		$.each(data[0].content.message.items,function(i,r){
					 html2 += '<tr>' 
							  +'<td>'+r.class_name+'</td>'
					          +'<td>'+r.class_credit+'</td>'
					          +'<td>'+r.class_type+'</td>'
					          +'<td>'+r.class_score+'</td>'
			               +'</tr>';
					 });
	 			}
	 			});
//	 html += ;
	 html=html+html2+'</table></div>';
	 return html;
 }
 //学校新闻
 function createOffnews(data){
	 var html = '<div class="office_news">'
		            +'<ul>';
	 if(!data["content"].message.items){
		 return null;
	 }
	 if(!(data["content"].message.items==0||data["content"].message.items==null)){
		 $.each(data["content"].message.items,function(i,r){
			 if(i==0){
				 html += '<a class="a_active" href="javascript:;"><li class="'+r["CATEGORY_ID"]+'">'+r["CATEGORY_NAME"]+'</li></a>';
			 }else{
				 html += '<a href="javascript:;"><li class="'+r["CATEGORY_ID"]+'">'+r["CATEGORY_NAME"]+'</li></a>';
			 }
		 });
	 }
	 var html1= '<div class="clear"></div></ul></div><div class="office_news_list"><ul>';
	 var _lm=data["content"].message.items[0].CATEGORY_NAME;
	 var _lmbh=data["content"].message.items[0].CATEGORY_ID;
	 $.ajaxSettings.async = false;
	 $.getJSON('/WDDXSERVER/bsdt/xwlb.action?userid='+user_id+'&ticket='+ticket+'&pagesize=5&pagenow=1',
		 {cc:_lm,
		  lmbh:_lmbh,
		  function_id:function_id
		 },
		 function(data){
			 if(!(data["content"].message.items==0||data["content"].message.items==null)){
				$.each(data["content"].message.items,function(i,r){
					html1 += '<li class="'+r["ARTICLE_ID"]+'">'
						       +'<div>'
//						       +'<a href="javascript:;" class="img">'+'<img src="'+r["ARTICLE_FACE"]+'"/>'+'</a>'
						          +'<a href="javascript:;" class="title">'+r["ARTICLE_TITLE"]+'</a>'+'<span>'+r["ARTICLE_DATE"]+'</span>'
						          +'<div class="clear"></div>'
						       +'</div>'
						    +'</li>';
				});
			 }
				html1 += '</ul></div>';
		 });
	 var html2='<div class="pagechange"><ul>'
		 +'<li class="nextpage"><a>下一页></a></li>'
		 +'<li class="index"><a>首页</a></li>'
		 +'<li class="previouspage"><a><上一页</a></li>'
		 +'</ul></div>';
	 html+=html1+html2;
	return html;
 }
 
 //跳蚤市场
 function createTZSC(data){
 		 var html='<div class="office_market">'
 			 +'<ul>'
 			 +'<li class="a_active"><a href="javascript:;" class="mdx1">买东西</a></li>'
 			 +'<li><a href="javascript:;" class="mdx2">卖东西</a></li>';
 		 html+='</ul></div>';
 		 html+='<div class="office_lists"><div class="office_market_list"><div class="office_market_search">'
 			 +'<a href="javascript:;" class="wdspsc"><img src="../../img/scdbb.png" /><p>收藏的宝贝</p></a>'
 			 +'<button class="Dzsplb">搜索</button><input type="text" class="spmcSs"></div>'
 			 +'<div class="office_market_zs_img"><img src="../../img/fksg_03.png" /></div>'
 			 +'<div class="office_market_function"><ul>';
 		if(!(data["content"].message.items==0||data["content"].message.items==null)){
	 		 $.each(data["content"].message.items,function(i,r){
	 			 html+='<li class="'+r["flbh"]+'"><a href="javascript:;"><img src="../../'+r["flfm"]+'" /><span>'+r["flmc"]+'</span></a></li>';
	 		 });
 		}
 		 html+='</ul></div></div></div>';
 		return html;
 }
 
 //绑定事件函数
 function bindYKT(){
	 var mydate = new Date();
	   var yy = "" + mydate.getFullYear();
	   var mm =mydate.getMonth()+1;
	   var mm1=mydate.getMonth();
	   var dd ="" + mydate.getDate();
	   var _jssj='';
	   var _kssj='';
	   if(mm<10){
		   _kssj=yy+'0'+mm1+dd;
		   _jssj=yy+'0'+mm+dd;
	   }else{
		   _kssj=yy+mm1+dd;
		   _jssj=yy+mm+dd;
	   }
	 yktList(_kssj,_jssj,1);
	 yktTablePage(_kssj,_jssj);
	 $(".starttime").datepicker({dateFormat: "yymmdd"});
	 $(".endtime").datepicker({dateFormat: "yymmdd"});
	 $('.search_mxcx').click(function(){
		 var _kssj1=$(".starttime").val();
		 var _jssj1=$(".endtime").val(); 
		 yktList(_kssj1,_jssj1,1);
		 yktTablePage(_kssj1,_jssj1);
	 });
 }

 //一卡通消费记录表
 function yktList(_kssj,_jssj,pageNum){
	  var html='<tr><th>'+"时间"+'</th>'
//	      +'<th>'+"地点"+'</th>'
	      +'<th>'+"金额"+'</th>'
	      +'<th>'+"余额"+'</th>'
		  +'</tr>';
	 $.ajax({
		 type:'POST',
		 async:false,
		 url:'/WDDXSERVER/bsdt/ykt_xfjl.action?function_id='+function_id+'&userid='+user_id+'&ticket='+ticket+'&pageSize=5'+'&pageNum='+pageNum+'&kssj='+_kssj+'&jssj='+_jssj,
		 success:function(data){
			 if(!(data["content"].message.items==0||data["content"].message.items==null)){
				 $.each(data["content"].message.items,function(i,r){
					 html+='<tr>'
							+'<td>'+r["JNDATETIME"]+'</td>'
	//						+'<td>'+r["CONSUME_AMOUNT"]+'</td>'
							+'<td>'+r["TRANAMT"]+'</td>'
							+'<td>'+r["CARD_BALANCE"]+'</td>'
							+'</tr>';
				 });
			 }
			$('.ykt_xfjl').empty().append(html);
			 
		 }
	 });
 }
 
 function yktTablePage(_kssj,_jssj){
	 var pageNum=1;
	 $('.pagechange ul li').unbind('click').click(function(){
		 var className=$(this).attr("class");
			 if(className=='nextpage'){
				 pageNum+=1;
				 yktList(_kssj,_jssj,pageNum);
			 }else if(className=='previouspage'){
				 pageNum-=1;
				 if(pagenow==0){pagenow=1;}
				 yktList(_kssj,_jssj,pageNum);
			 }else{
				 pageNum=1;
				 yktList(_kssj,_jssj,pageNum);
			 }
	 });
 }
 
 //绑定图书馆事件
 function bindlibrary(){}
 //绑定通讯录事件
 function bindOffPhone(){
	 $('div.content .office_phone_bm ul li a').click(function(e){
		 var _domId = $(this).attr("path");
//		 var a = $('#'+_domId);
		 $(this).parent().siblings().removeClass("active");
		 $(this).parent().addClass("active");
		 $('#'+_domId).siblings().not(".office_phone_bm").removeClass("office_phone_block").addClass("office_phone_none");
		 $('#'+_domId).removeClass("office_phone_none").addClass("office_phone_block");
	 });

	 $('.search').click(function(){
		 var pid=$('.office_phone_bm ul li.active').children('a').attr('class');
		 var doms = $('div.office_phone_block').children().clone(true);
	    	$('div.office_phone_block').children().remove();
	    	$('input.searchText').hide(0);
	    	$('span.search').hide(0);
	    	$('a.back-reveal-modal').show(0);
	    	$('a.back-reveal-modal').unbind('click').click(function(){
	    		$(this).hide(0);
	    		$('input.searchText').show(0);
		    	$('span.search').show(0);
	    		$('div.searchList').remove();
	    		$('div.office_phone_block').append(doms);
	    	});
		 SsPhone(pid); 
	 });
 }
 function SsPhone(pid){
	 var cxtj=$('.searchText').val();
	 var html='';
	 $.ajaxSettings.async = false;
		$.getJSON("/WDDXSERVER/bsdt/txlss.action?userid="+user_id+"&ticket="+ticket, 
		 		{ pid: pid,
				  function_id:function_id,
				  cxtj:cxtj
				 },
		 		function(data) { 
					 if(!(data.content.message==0||data.content.message==null)){
				 		$.each(data.content.message,function(i,r){
				 			html='<div class="searchList">'
			                  +'<div class="title">'
						         +'<a>'
						            + r["txl_name"]  
						         +'</a>' 
						      +'</div>'
						      +'<span>'
			                     +'<a>'
							        + r["txl_name"]
		                         +'</a>'
		                         +'<a href="javascript:;">'
		                            + r["txl_zjhm"]
		                         +'</a>'
				              +'</span>';
					       + '<div>';
						 });  
					 }
		});
		$('.content div.office_phone_block').empty().append(html);
 }
 
 //教室查询绑定事件
 function bindclassRoom(){
	 $(".xq select").change(function(e){
			var _xq=$(this).val();
			var html2 = '<p>选择教学楼</p><select>';
			$.ajaxSettings.async = false;
			$.getJSON("/WDDXSERVER/bsdt/jscxlh.action?userid="+user_id+"&ticket="+ticket, 
			 		{ xq: _xq,
					  function_id:function_id
					},
			 		function(data) { 
						if(!(data.content.message.items==0||data.content.message.items==null)){
					 		$.each(data.content.message.items,function(i,r){
					 			html2+='<option>'+r["LH"]+'</option>';
							 });  
						}
			});
			html2+='</select>';
			$('.jxl').empty().append(html2);
		 });
	 
	 $('div.office_btn a').click(function(e){
		 	var _xq=$('.xq select').val();
			var _lh=$('.jxl select').val();
			var _djj=$('.classjc select').val();
	    	var doms = $('.content').children().clone(true);
	    	$('.content').children().remove();
	    	$('a.back-reveal-modal').show(0);
	    	$('a.back-reveal-modal').unbind('click').click(function(){
	    		$(this).hide(0);
	    		$('div.cxjg').remove();
	    		$('.content').append(doms);
	    	});
	    	 var htmls = '<div class="cxjg">'
	               +'<table>'
	                  +'<tr>'
	                     +'<th>'+"教学楼"+'</th>'
	                     +'<th>'+"教室名称"+'</th>'
	                     +'<th>'+"座位数"+'</th>'
	                     +'<th>'+"教室信息"+'</th>'
	                  +'</tr>';
	    	 var htmle = '';
			 $.ajaxSettings.async = false;
				$.getJSON('/WDDXSERVER/bsdt/jscxlb.action?userid='+user_id+'&ticket='+ticket, 
			 		{ xq:_xq,
			 		 lh:_lh,
			 		 djj:_djj,
			 		function_id:function_id
			 		 },
			 		function(data) { 
			 			if(!(data["content"].message.items==0||data["content"].message.items==null)){
				 			$.each(data["content"].message.items,function(i,r){
				 			 htmle += '<tr>' 
								  +'<td>'+r["LH"]+'</td>'
						          +'<td>'+r["JSMC"]+'</td>'
						          +'<td>'+r["ZWS"]+'</td>'
						          +'<td>'+r["JSLB"]+'</td>'
				               +'</tr>';
							});
			 			}
			 	});
			 
			 htmls+=htmle+'</table></div>';
	        $('.content').append(htmls);
	    });
			
 }
 //班车查询绑定事件
 function bindOffBus(){}
 //成绩查询绑定事件
 function bindOffScore(){
	 $("#xq").change(function(){
		var _rm_xq=$(this).val();
		var html='';
		var html1= '<tr>'
			        +'<th>'+"课程名称"+'</th>'
			        +'<th>'+"学分"+'</th>'
			        +'<th>'+"课程性质"+'</th>'
			        +'<th>'+"成绩"+'</th>'
			     +'</tr>';
		var html2='';
		$.ajaxSettings.async = false;
		$.getJSON("/WDDXSERVER/home/getCJForPc.action?userid="+user_id+"&ticket="+ticket, 
	 		{ rm_xq: _rm_xq },
	 		function(data) { 
	 			if(!(data[0].content.message.items==0||data[0].content.message.items==null)){
			 		$.each(data[0].content.message.items,function(i,r){
					 html2 += '<tr>' 
							  +'<td>'+r.class_name+'</td>'
					          +'<td>'+r.class_credit+'</td>'
					          +'<td>'+r.class_type+'</td>'
					          +'<td>'+r.class_score+'</td>'
			               +'</tr>';
					 });
	 			}
	 	});
		 html=html1+html2;
		 $('.office_cjcx table').empty().append(html);
	 });
	
 }
 //学校新闻绑定事件
 function bindOffnews(){
	 $('div.content .office_news ul a li').click(function(e){
		 var _lmbh = $(this).attr("class");
		 var _cc=$(this).text();
		 $(this).parent().siblings().removeClass("a_active");
		 $(this).parent().addClass("a_active");
		 var html1= '<ul>';
//		 var _xwbh=ARTICLE_ID
		 $.ajaxSettings.async = false;
		 $.getJSON('/WDDXSERVER/bsdt/xwlb.action?userid='+user_id+'&ticket='+ticket+'&pagesize=5&pagenow=1',
			 {cc:_cc,
			 lmbh:_lmbh,
			 function_id:function_id
			 },
			 function(data){
				 if(!(data["content"].message.items==0||data["content"].message.items==null)){
					$.each(data["content"].message.items,function(i,r){
						html1 += '<li  class="'+r["ARTICLE_ID"]+'">'
							       +'<div>'
//							       +'<a href="javascript:;" class="img">'+'<img src="'+r["ARTICLE_FACE"]+'"/>'+'</a>'
							          +'<a href="javascript:;" class="title">'+r["ARTICLE_TITLE"]+'</a>'+'<span>'+r["ARTICLE_DATE"]+'</span>'
							          +'<div class="clear"></div>'
							       +'</div>'
							    +'</li>';
					});
				 }
					html1 += '</ul>';
			 });
		 $('.office_news_list').empty().append(html1);
		 changeArticle();
	 });
	 changeArticle();
	 var pagenow=1;
	 $('.pagechange ul li').unbind('click').click(function(){
		 var className=$(this).attr("class");
			 if(className=='nextpage'){
				 pagenow+=1;
				 changeNewList(pagenow);
			 }else if(className=='previouspage'){
				 pagenow-=1;
				 if(pagenow==0){pagenow=1;}
				 changeNewList(pagenow);
			 }else{
				 pagenow=1;
				 changeNewList(pagenow);
			 }
	 });
	 
	
		
 }
 
 //学习新闻列表切换
 function changeNewList(pagenow){
	 var _lmbh = $('.office_news ul a li').attr("class");
	 var _cc=$('.office_news ul a li').text();
		 var html1= '<ul>';
		 $.ajaxSettings.async = false;
		 $.getJSON('/WDDXSERVER/bsdt/xwlb.action?userid='+user_id+'&ticket='+ticket+'&pagesize=5&pagenow='+pagenow,
			 {cc:_cc,
			 lmbh:_lmbh,
			 function_id:function_id
			 },
			 function(data){
				 if(!(data["content"].message.items==0||data["content"].message.items==null)){
					$.each(data["content"].message.items,function(i,r){
						html1 += '<li  class="'+r["ARTICLE_ID"]+'">'
							       +'<div>'
//							       +'<a href="javascript:;" class="img">'+'<img src="'+r["ARTICLE_FACE"]+'"/>'+'</a>'
							          +'<a href="javascript:;" class="title">'+r["ARTICLE_TITLE"]+'</a>'+'<span>'+r["ARTICLE_DATE"]+'</span>'
							          +'<div class="clear"></div>'
							       +'</div>'
							    +'</li>';
					});
				 }
					html1 += '</ul>';
					$('.office_news_list').empty().append(html1);
		 });
		 changeArticle();
 }
 
 //进入学校新闻内容
 function changeArticle(){
	 $('div.content .office_news_list ul li a').click(function(){
			var _xwbh=$(this).parent().parent().attr("class");
			var _cc=$(this).text();
			var doms = $('.content').children().clone(true);
	    	$('.content').children().remove();
	    	$('a.back-reveal-modal').show(0);
	    	$('a.back-reveal-modal').unbind('click').click(function(){
	    		$(this).hide(0);
	    		$('div.office_list_article').remove();
	    		$('.content').append(doms);
	    	});
			var html='';
			 $.ajaxSettings.async = false;
			 $.getJSON('/WDDXSERVER/bsdt/xwnr.action?userid='+user_id+'&ticket='+ticket,
					 {
				 		xwbh:_xwbh,
				 		cc:_cc,
				 		function_id:function_id
					 },
			 		function(data){
						 if(!(data["content"].message.items==0||data["content"].message.items==null)){
							$.each(data["content"].message.items,function(i,r){
								html='<div class="office_list_article">'
									+'<h5>'+r["ARTICLE_TITLE"]+'</h5><span>'+r["ARTICLE_DATE"]+'</span>'
									+'<h4>'+r["ARTICLE_TITLE"]+'</h4>'
									+'<div class="list_article">'+r["ARTICLE_CLOB"]+'</div></div>';
							});
						 }
			 		});
			 $('.content').append(html);
		});
 }
 
 //跳蚤市场应用
function bindTZSC(){
	 onSallsp();              //卖东西
	 tzscSclb();             //商品收藏列表
	 tzscLb();              //商品列表
	 tzscDzsplb();   //搜索
 }
 //买卖列表标题(卖东西)
 function onSallsp(){
	 var sun=0;
	 sun++;
	 var _mmlx=2;
	 var dom='';
		$('.mdx2').click(function(){
			 dom=$('.office_market_list').clone(true);
			 $(this).parent().siblings().removeClass("a_active");
			 $(this).parent().addClass("a_active");
	    	$('.office_market_list').remove();
	    	$('.mdx1').unbind('click').click(function(){
	    		 $(this).parent().siblings().removeClass("a_active");
	    		 $(this).parent().addClass("a_active");
	    		$('div.office_market_list_sall').remove();
	    		$('div.pagechange').remove();
	    		$('div.office_market_list_salls').remove();
	    		$('.content').append(dom);
//	    		tzscLb();
//	    		tzscSclb();
//	    		tzscDzsplb();
	    	});
	    	var html='<div class="office_market_list_salls">'
				 	+'<a href="javascript:;" class="tzsc_spfb"><img src="../../img/add_03.png" /><span>发布商品</span></a></div>'
				 	+'<div class="office_market_list_sall"><ul>';
	    	var html1='';
			$.ajaxSettings.async=false;
			$.getJSON('/WDDXSERVER/bsdt/tzsc_wdsplb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&pageNum=1',
				  {
					function_id:function_id,
					mmlx:_mmlx
				  },
				  function(data){
					  if(!(data["content"].message.items==0||data["content"].message.items==null)){
				 		 $.each(data["content"].message.items,function(i,r){
				 			html1+='<li class="'+r["spid"]+'" id="'+r["flid"]+'" spms="'+r["spms"]+'" splx="'+r["flmc"]+'" spmc="'+r["spmc"]+'" spzt="'+r["spzt"]+'">'
				 			+'<a href="javascript:;" ><div><img src="'+r["fjdz"]+'" /></div><span '+r["spjg"]+'>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
				 		 });
					  }
				  });
				html+=html1+'</ul></div>'
				+'<div class="pagechange"><ul>'
				+'<li class="nextpage"><a href="javascript:;">下一页></a></li>'
				+'<li class="index"><a href="javascript:;">首页</a></li>'
				+'<li class="previouspage"><a href="javascript:;"><上一页</a></li>'
				+'</ul></div>';
				$('.office_lists').empty().append(html);
			//商品发布
			tzscSpfb();	
			//商品下架
			tzscSpxj();
			fyWdsplb(_mmlx);
		});	 
		
}
 function fyWdsplb(_mmlx){
	 var pageNum=1;
	 $('.pagechange ul li').unbind('click').click(function(){
		 var className=$(this).attr("class");
			 if(className=='nextpage'){
				 pageNum+=1;
				 pageWdsplb(_mmlx,pageNum);
			 }else if(className=='previouspage'){
				 pageNum-=1;
				 if(pageNum==0){ pageNum=1;}
				 pageWdsplb(_mmlx,pageNum);
			 }else{
				 pageNum=1;
				 pageWdsplb(_mmlx,pageNum);
			 }
});
}
function pageWdsplb(_mmlx,pageNum){
	 var html='<div class="office_fun_info"><ul>';
		$.ajaxSettings.async=false;
		$.getJSON('/WDDXSERVER/bsdt/tzsc_wdsplb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3',
			  {
				function_id:function_id,
				mmlx:_mmlx,
		 		pageNum:pageNum
			  },
			  function(data){
				  if(!(data["content"].message.items==0||data["content"].message.items==null)){
			 		 $.each(data["content"].message.items,function(i,r){
							html+='<li class="'+r["spid"]+'" id="'+r["flid"]+'">'
							+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
			 		 });
				  }
			  });
		html+='</ul></div>'
			+'</div>';
		$('.office_market_list_sall').empty().append(html);
		//商品发布
		tzscSpfb();	
		//商品下架
		tzscSpxj();
}
 
 //商品列表

 function tzscLb(){
	 $('.office_market_function ul li').click(function(e){
		 var px='k';
		 var _flbh=$(this).attr('class');
//		 var splx=$(this).children().text();
		  var doms = $('.content').children().clone(true);
	    	$('.content').children().remove();
	    	$('a.back-reveal-modal').show(0);
	    	$('a.back-reveal-modal').unbind('click').click(function(){
	    		$(this).hide(0);
	    		$('div.office_phone').remove();
	    		$('.content').append(doms);
	    	});
	   	 var html='<div class="office_phone"><div class="office_fun_title"><ul>'
			 	+'<li class="a_active"><a href="javascript:;" class="k">最新</a></li>'
			 	+'<li><a href="javascript:;" class="j">价格由高到低</a></li>'
			 	+'<li><a href="javascript:;" class="s">价格由低到高</a></li></ul></div>'
			 	+'<div class="office_fun_info"><ul>';
		$.ajaxSettings.async=false;
		$.getJSON('/WDDXSERVER/bsdt/tzsc_splb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&pageNum=1',
			  {
				function_id:function_id,
		 		flbh:_flbh,
		 		px:px
			  },
			  function(data){
				  if(!(data["content"].message.items==0||data["content"].message.items==null)){
			 		 $.each(data["content"].message.items,function(i,r){
							html+='<li class="'+r["spid"]+'" id="'+r["flid"]+'">'
							+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
			 		 });
				  }
			  });
		html+='</ul></div>'
			+'<div class="pagechange"><ul>'
			+'<li class="nextpage"><a href="javascript:;">下一页></a></li>'
			+'<li class="index"><a href="javascript:;">首页</a></li>'
			+'<li class="previouspage"><a href="javascript:;"><上一页</a></li>'
			+'</ul></div>'
			+'</div>';
		$('.content').append(html);
		tzscSpxq(doms);
		//商品排序
		tzscSppx(_flbh,doms);
		fySplb(_flbh,doms,px);
	 });
 }
 function fySplb(_flbh,doms,px){
	 var pageNum=1;
	 $('.pagechange ul li').unbind('click').click(function(){
		 var className=$(this).attr("class");
			 if(className=='nextpage'){
				 pageNum+=1;
				 pageSplb(_flbh,pageNum,doms,px);
			 }else if(className=='previouspage'){
				 pageNum-=1;
				 if(pageNum==0){pageNum=1;}
				 pageSplb(_flbh,pageNum,doms,px);
			 }else{
				 pageNum=1;
				 pageSplb(_flbh,pageNum,doms,px);
			 }
 });
 }
 function pageSplb(_flbh,pageNum,doms,px){
   	 var html='<div class="office_fun_info"><ul>';
	$.ajaxSettings.async=false;
	$.getJSON('/WDDXSERVER/bsdt/tzsc_splb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3',
		  {
			function_id:function_id,
	 		flbh:_flbh,
	 		pageNum:pageNum,
	 		px:px
		  },
		  function(data){
			  if(!(data["content"].message.items==0||data["content"].message.items==null)){
		 		 $.each(data["content"].message.items,function(i,r){
						html+='<li class="'+r["spid"]+'" id="'+r["flid"]+'">'
						+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
		 		 });
			  }
		  });
	html+='</ul></div>'
		+'</div>';
	$('.office_fun_info').empty().append(html);
	tzscSpxq(doms);
 }
 
 //商品详情
 function tzscSpxq(index_doms){
	 $('div.office_phone div.office_fun_title ul li a').click(function(){
		 $(this).parent().siblings().removeClass("a_active");
		 $(this).parent().addClass("a_active");	
	 });
	 $('.office_fun_info ul li').click(function(){
		 var _flbh=$(this).attr('id');
		 var _spid=$(this).attr('class');
		 var doms = $('.content').children().clone(true);
    	 $('.content').children().remove();
    	 $('a.back-reveal-modal').show(0);
    	 $('a.back-reveal-modal').unbind('click').click(function(){
    		$('div.tzsc_shop_xq').remove();
    		$('.content').append(doms);
    		 $('a.back-reveal-modal').unbind('click').click(function(){
    	    		$(this).hide(0);
    	    		$('div.office_phone').remove();
    	    		$('.content').append(index_doms);
    	    		
    	    	 });
    	 });
    	 var html='<div class="tzsc_shop_xq"><div class="shop_message"><div class="shop_img">';
    	  $.ajaxSettings.async=false;
          $.getJSON('/WDDXSERVER/bsdt/tzsc_spxq.action?userid='+user_id+'&ticket='+ticket,
        		  {
        	  	  function_id:function_id,
        	      spid:_spid
    	    	 },
        		  function(data){
    	    		 if(!(data["content"].message.items==0||data["content"].message.items==null)){
	    	    		 $.each(data["content"].message.items,function(i,r){
	    	   	    			html+='<img src="'+data["content"].message.items[i].fjdz+'"/>';
	    	   	    		 });
	    	    		 html+='</div>'
	    	    			 +'<a href="javascript:;" class="spsc" id="'+data["content"].message.items[0].spzt+'"><img src="../../img/scdbb.png"/><span>收藏</span></a>'
	    	    			 +'<a href="javascript:;"><span>'+data["content"].message.items[0].lxdh+'</span><img src="../../img/phone.png"/></a>'
	    	    			 +'<p><label>商品描述：</label><span>'+data["content"].message.items[0].spms+'</span></p>'
    	    			 +'</div>'
    	    			 +'<div class="shop_info"><h5>'+data["content"].message.items[0].spmc+'</h5>'
    	    			 	+'<div class="shop_price"><a href="javascript:;" class="tzsc_jbsp">举报</a>'
	    	    			+'<p><label>商品售价</label><span>￥'+data["content"].message.items[0].spjg+'</span></p>'
	    	    			+'<p><label>商品类型</label><span>'+data["content"].message.items[0].flmc+'</span></p>'
    	    			 +'</div>'
    	    			 +'<p>给卖家留言：</p>'
    	    			 +'<div class="ly" contenteditable="true"></div>'
    	    			 +'<button class="sendmsg">发送</button>'
	    			 +'</div></div>';
    	    		 }
	        		  });
          $('.content').append(html);
          //商品收藏
          tzscSpsc(_spid);
          //商品举报
          tzscJbsp(_flbh);
	 });
 }
 
 //排序
 function tzscSppx(_flbh,doms){
	 $('.office_fun_title ul li a').click(function(){
		 var px=$(this).attr('class');
		 var html='<div class="office_fun_info"><ul>';
		$.ajaxSettings.async=false;
		$.getJSON('/WDDXSERVER/bsdt/tzsc_splb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&pageNum=1',
			  {
				function_id:function_id,
		 		flbh:_flbh,
		 		px:px
			  },
			  function(data){
				  if(!(data["content"].message.items==0||data["content"].message.items==null)){
			 		 $.each(data["content"].message.items,function(i,r){
							html+='<li class="'+r["spid"]+'" id="'+r["flid"]+'">'
							+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
			 		 });
				  }
			  });
		html+='</ul></div>';
		$('.office_fun_info').empty().append(html);
		tzscSpxq(doms);	
		fySplb(_flbh,doms,px);
	 });
 }
 //商品收藏
 function tzscSpsc(_spid){
	 var num=0; 
	 $('.spsc').click(function(e){ 
		 var _spzt=$(this).attr('id');
	 if(num++ %2 == 0){ 
		$('.spsc span').text('已收藏');
		$.ajaxSettings.async=false;
		$.getJSON('/WDDXSERVER/bsdt/tzsc_Scsp.action?function_id=20150117&userid='+user_id+'&ticket='+ticket,
			  {
				spbh:_spid,
				spzt:_spzt
			  },
			  function(data){}
			  );
	 }else{ 
		 $('.spsc span').text('收藏');
	 } 
	 }); 
 }

 //商品收藏列表

 function tzscSclb(){
	 $('.wdspsc').click(function(){
		 var px='k';
		 $('div.office_phone div.office_fun_title ul li a').click(function(){
			 $(this).parent().siblings().removeClass("a_active");
			 $(this).parent().addClass("a_active");	
		 });
		var doms= $('.content').children().clone(true);
		 $('.content').children().remove();
	    	$('a.back-reveal-modal').show(0);
	    	$('a.back-reveal-modal').unbind('click').click(function(){
	    		$(this).hide(0);
	    		$('.office_fun_title').remove();
	    		$('div.office_fun_info').remove();
	    		$('div.pagechange').remove();
//	    		$('.content').children().remove();
	    		$('.content').append(doms);
	    	});
	 var html='<div class="office_phone"><div class="office_fun_title"><ul>'
				 	+'<li class="a_active"><a href="javascript:;" class="k">最新</a></li>'
				 	+'<li><a href="javascript:;" class="j">价格由高到低</a></li>'
				 	+'<li><a href="javascript:;" class="s">价格由低到高</a></li></ul></div>'
			+'<div class="office_fun_info">'
		 	+'<ul>';
	$.ajaxSettings.async=false;
	$.getJSON('/WDDXSERVER/bsdt/tzsc_Sclb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&nowpage=1',
		  {
		function_id:function_id,
		px:px
		  },
		  function(data){
			  if(!(data["content"].message.items==0||data["content"].message.items==null)){
				 $.each(data["content"].message.items,function(i,r){
						html+='<li class="'+r["spid"]+'">'
						+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
				 });
			  }
		  });
	html+='</ul></div>'
		+'<div class="pagechange"><ul>'
		+'<li class="nextpage"><a href="javascript:;">下一页></a></li>'
		+'<li class="index"><a href="javascript:;">首页</a></li>'
		+'<li class="previouspage"><a href="javascript:;"><上一页</a></li>'
		+'</ul></div>';
	$('.content').append(html);	
	tzscSpxqSc(doms);
	//收藏页面商品排序
	sclbPx(doms);
	fySclb(doms,px);
	 });
 }

 //商品收藏详情
 function tzscSpxqSc(index_doms){
	 $('div.office_phone div.office_fun_title ul li a').click(function(){
		 $(this).parent().siblings().removeClass("a_active");
		 $(this).parent().addClass("a_active");	
	 });
	 $('.office_fun_info ul li').click(function(){
		 var _spid=$(this).attr('class');
		 var doms = $('.content').children().clone(true);
    	 $('.content').children().remove();
    	 $('a.back-reveal-modal').show(0);
    	 $('a.back-reveal-modal').unbind('click').click(function(){
    		$('div.tzsc_shop_xq').remove();
    		$('.content').append(doms);
    		 $('a.back-reveal-modal').unbind('click').click(function(){
    	    		$(this).hide(0);
    	    		$('div.office_phone').remove();
    	    		$('.content').append(index_doms);
    	    		
    	    	 });
    	 });
    	 var  html='<div class="tzsc_shop_xq"><div class="shop_message"><div class="shop_img">';
    	  $.ajaxSettings.async=false;
          $.getJSON('/WDDXSERVER/bsdt/tzsc_spxq.action?userid='+user_id+'&ticket='+ticket,
        		  {
        	  	  function_id:function_id,
        	      spid:_spid
    	    	 },
        		  function(data){
    	    		if(!(data["content"].message.items==0||data["content"].message.items==null)){
    	    		 $.each(data["content"].message.items,function(i,r){
 	   	    			html+='<img src="'+data["content"].message.items[i].fjdz+'"/>';
 	   	    		 });
	    	    		html+='</div>'
	    	    			 +'<a href="javascript:;" class="spsc" id="'+data["content"].message.items[0].spzt+'"><img src="../../img/scdbb.png"/><span>已收藏</span></a>'
	    	    			 +'<a href="javascript:;"><span>'+data["content"].message.items[0].lxdh+'</span><img src="../../img/phone.png"/></a>'
	    	    			 +'<p><label>商品描述：</label><span>'+data["content"].message.items[0].spms+'</span></p>'
    	    			 +'</div>'
    	    			 +'<div class="shop_info"><h5>'+data["content"].message.items[0].spmc+'</h5>'
    	    			 	+'<div class="shop_price"><a href="javascript:;" class="tzsc_jbsp">举报</a>'
	    	    			+'<p><label>商品售价</label><span>￥'+data["content"].message.items[0].spjg+'</span></p>'
	    	    			+'<p><label>商品类型</label><span>'+data["content"].message.items[0].flmc+'</span></p>'
    	    			 +'</div>'
    	    			 +'<p>给卖家留言：</p>'
    	    			 +'<div class="ly" contenteditable="true"></div>'
    	    			 +'<button class="sendmsg">发送</button>'
	    			 +'</div></div>';
    	    		}
        		  });
          $('.content').append(html);
          //取消收藏
          tascQxsc(_spid);
          //商品举报
          tzscJbsp(_spid);
	 });
 }
 
 
 function fySclb(doms,px){
	 var pageNum=1;
	 $('.pagechange ul li').unbind('click').click(function(){
		 var className=$(this).attr("class");
			 if(className=='nextpage'){
				 pageNum+=1;
				 pageSclb(pageNum,doms,px);
			 }else if(className=='previouspage'){
				 pageNum-=1;
				 if(pageNum==0){pageNum=1;}
				 pageSclb(pageNum,doms,px);
			 }else{
				 pageNum=1;
				 pageSclb(pageNum,doms,px);
			 }
 });
 }
 function pageSclb(pageNum,doms,px){
   	 var html='<div class="office_fun_info"><ul>';
	$.ajaxSettings.async=false;
	$.getJSON('/WDDXSERVER/bsdt/tzsc_Sclb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3',
		  {
			function_id:function_id,
	 		nowpage:pageNum,
	 		px:px
		  },
		  function(data){
			  if(!(data["content"].message.items==0||data["content"].message.items==null)){
		 		 $.each(data["content"].message.items,function(i,r){
						html+='<li class="'+r["spid"]+'" id="'+r["flid"]+'">'
						+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
		 		 });
			  }
		  });
	html+='</ul></div>'
		+'</div>';
	$('.office_fun_info').empty().append(html);
	tzscSpxqSc(doms);
 }
//商品排序
 function sclbPx(doms){
	 $('.office_fun_title ul li a').click(function(){
		 var px=$(this).attr('class');
		 var html='<div class="office_fun_info"><ul>';
		$.ajaxSettings.async=false;
		$.getJSON('/WDDXSERVER/bsdt/tzsc_Sclb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&nowpage=1',
			  {
				function_id:function_id,
		 		px:px,
			  },
			  function(data){
				  if(!(data["content"].message.items==0||data["content"].message.items==null)){
			 		 $.each(data["content"].message.items,function(i,r){
							html+='<li class="'+r["spid"]+'">'
							+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
			 		 });
				  }
			  });
		html+='</ul></div>';
		$('.office_fun_info').empty().append(html);
		tzscSpxqSc(doms);	
		fySclb(doms,px);
	 });
	 
 }
 
 //取消商品收藏
 function tascQxsc(_flbh){
	 $('.spsc').click(function(){
		 $('.spsc span').text('收藏');
		 $.ajaxSettings.async=false;
			$.getJSON('/WDDXSERVER/bsdt/tzsc_Qxsc.action?function_id=20150117&userid='+user_id+'&ticket='+ticket,
				  {
				spbh:_flbh
				  },
				  function(data){});
	 });
 }
 
//举报商品
 function tzscJbsp(_flbh){
	 var _jbyy="no";
	 $('.tzsc_jbsp').click(function(){
		 $.ajaxSettings.async=false;
			$.getJSON('/WDDXSERVER/bsdt/tzsc_Spjb.action?userid='+user_id+'&ticket='+ticket,
				  {
				   spbh:_flbh,
				   jbrbh:user_id,
				   function_id:function_id,
				   jbyy:_jbyy
				  },
				  function(data){
					  alert("已举报");
				  });
		 
	 });
 }
 
 //商品发布
 function tzscSpfb(){
	 $('.tzsc_spfb').click(function(){
		 num=0;
		 var doms= $('.content').children().clone(true);
		 $('.content').children().remove();
	    	$('a.back-reveal-modal').show(0);
	    	$('a.back-reveal-modal').unbind('click').click(function(){
	    		$(this).hide(0);
	    		$('.office_tzsc_spfb').remove();
	    		$('.content').append(doms);
	    		num=0;
	    	});
		 
		 var html='<div class="office_tzsc_spfb">'
			 +'<p>商品名称</p><input type="text" placeholder="单行输入" class="spmc">'
			 +'<p>商品类型</p><select class="splx">'
				 +'<option value="1">手机</option>'
				 +'<option value="2">摄像器材</option>'
				 +'<option value="3">数码游戏</option>'
				 +'<option value="4">电脑配件</option>'
				 +'<option value="5">女装</option>'
				 +'<option value="6">男装</option>'
				 +'<option value="7">鞋包/配饰</option>'
				 +'<option value="8">香水/美容</option>'
				 +'<option value="9">书籍/影音</option>'
				 +'<option value="10">食品/水果</option>'
				 +'<option value="11">体育用品</option>'
				 +'<option value="12">其他</option>'
			 +'</select>'
			 +'<p>商品状态</p><select class="spzt">'
				 +'<option  value="1">正常</option>'
				 +'<option  value="2">缺货</option>'
				 +'<option  value="3">打折</option>'
				 +'<option  value="4">热卖</option>'
				 +'<option  value="5">推荐</option>'
			 +'</select>'
			 +'<p>联系价格</p><input type="text" placeholder="请输入商品价格（只允许数字）" class="spjg">'
			 +'<p>联系电话</p><input type="text" placeholder="请输入联系电话（只允许数字）" class="lxdh" maxlength="11">'
			 +'<p>商品描述</p><textarea  placeholder="请输入商品描述" class="spms"></textarea>'
			 +'<p>照片</p>'
			 +'<div class="imgs">'
			 	+'<form class="upload" id="fileForm" method="post" action="/FS/loadpic/loadpicsform.action?" name="fileForm1" enctype="multipart/form-data" >'
			 	+'<img src="../../img/addimg.png" id="xmTanImg" class="xmTanImg"/><p>添加照片</p>'
			 	+'<input type="file" name="file" class="upload_img" id="tascUploadImg" onchange="xmTanUploadImg(this)"/>'
			 +'</form></div>'
	         +'<div id="xmTanDiv"></div>'
	         +'<iframe name="uploadFrame" id="uploadFrame" style="display:none;"></iframe>'
			 +'<input class="submit" type="button" value="提交">'
			 +'</div>';
	$('.content').empty().append(html);
	upLoadImg();
	 });
 }
 
//判断浏览器是否支持FileReader接口
if (typeof FileReader == 'undefined') {
    document.getElementById("xmTanDiv").InnerHTML = "<h1>当前浏览器不支持FileReader接口</h1>";
    //使选择控件不可操作
    document.getElementById("tascUploadImg").setAttribute("disabled", "disabled");
}

//选择图片，马上预览
var num=0;
//var upl=$('.upload').clone(true);
function xmTanUploadImg(obj) {
	num++;
	var upl=$('.upload').clone(true);
    var file = obj.files[0];               // console.log(obj);console.log(file);
    console.log("file.size = " + file.size);  //file.size 单位为byte
    var reader = new FileReader();
    //读取文件过程方法
    reader.onloadstart = function (e) {
        console.log("开始读取....");
    };
    reader.onprogress = function (e) {
        console.log("正在读取中....");
    };
    reader.onabort = function (e) {
        console.log("中断读取....");
    };
    reader.onerror = function (e) {
        console.log("读取异常....");
    };
    reader.onload = function (e) {
        console.log("成功读取....");
	    var img = document.getElementById("xmTanImg");
	    img.src = e.target.result;
	    //或者 img.src = this.result;  //e.target == this
	            };
    reader.readAsDataURL(file);
    if(num<6){
    	 $('.imgs').prepend(upl);
    	 $('.imgs p:first').remove();
    }else{
    	alert("一次最多只能上传5张");
    }    
    $('.imgs form:first').css({"padding-top":"0","height":"81px","margin-right":"1em"});
    $('.imgs form img:first').css({"width":"100%"});
    $('.imgs form img:first').css({"height":"100%"});
    $('.imgs form:first').attr({"id":"fileForm"+num});
    $('.imgs form:first').attr({"class":"upload"+num});
    $('.imgs form input:first').attr({"class":"upload_img"+num});
    $('.imgs form input:first').attr({"disabled":"true"});
    var upload=$('.upload_img').val();
    $('.imgs form input:first').attr({"value":upload});
    subimtBtn();
    
}

//form上传图片回调
var _fjlb=[];
function subimtBtn() {  
	var jsondata='';
	 $("#fileForm").ajaxForm({   
		 	dataType: "json",
//		 	url:'http://desktop-mgjr52l:8080/loadpic/loadpicsform.action?',    
	        type:'post', 
	        success:function(data){
	        	jsondata=data["list"][0].OriginalImage;
//	        	console.log(data["list"][0].OriginalImage);
	        }
	    }).submit();
	 _fjlb.push(jsondata);
} 
 //跳蚤市场-发布商品信息
function upLoadImg(){
	 $('.submit').click(function(){
		 addData();
	 });
}

function addData(){
	 var _spmc=$('.spmc').val();
	 var _splx=$('.splx option:selected').val();
	 var _spjg=$('.spjg').val();
	 var _spms=$('.spms').val();
	 var _spzt=$('.spzt option:selected').val();
	 var _lxdh=$('.lxdh').val();
	 var _mmlx=2;
	 $.ajax({
		 url:'/WDDXSERVER/bsdt/tzsc_Fbsp.action?userid='+user_id+'&ticket='+ticket,
	    	type:'get',
	    	data:{
	    		function_id:function_id,
	    		spmc:_spmc,
	    		splx:_splx,
	    		spjg:_spjg,
	    		spms:_spms,
	    		spzt:_spzt,
	    		lxdh:_lxdh,
	    		mmlx:_mmlx,
	    		spfbr:user_id,
	    		pics:_fjlb.join()    //数组转换成字符串
	    	},
	    	dataType:'json',
	    	success:function(data){}
	 });
}

//我的买卖列表详情
function tzscSpxj(){
	 $('.office_market_list_sall ul li').click(function(){
//		 var _flbh=$(this).attr('id');
		 var _spid=$(this).attr('class');
		 var spms='';
		 var spmc='';
//		 var splx=$(this).attr('splx');
		 var _spzt=$(this).attr('spzt');
		 var src=$(this).children().children().children().attr('src');
		 var doms = $('.content').children().clone(true);
	   	 $('.content').children().remove();
	   	 $('a.back-reveal-modal').show(0);
	   	 $('a.back-reveal-modal').unbind('click').click(function(){
	   		$(this).hide(0);
   		 $('div.tzsc_shop_xj').remove();
   		$('.content').append(doms);
   	 });
   	 var html='<div class="tzsc_shop_xj"><div class="shop_message"><div class="shop_img">';
   	  $.ajaxSettings.async=false;
         $.getJSON('/WDDXSERVER/bsdt/tzsc_spxq.action?function_id=20150117&userid='+user_id+'&ticket='+ticket,
       		  {
       	      spid:_spid
   	    	 },
       		  function(data){
   	    		if(!(data["content"].message.items==0||data["content"].message.items==null)){
   	    		 $.each(data["content"].message.items,function(i,r){
   	    			html+='<img src="'+data["content"].message.items[i].fjdz+'"/>';
   	    		 });
   	    		 spms=data["content"].message.items[0].spms;
   	    		 spmc=data["content"].message.items[0].spmc;
   	    		_spzt=data["content"].message.items[0].spshzt;
   	    		   html+='</div>'
    	    			 +'<a href="javascript:;" class="spsc"><img src="../../img/scdbb.png"/><span>收藏</span></a>'
    	    			 +'<a href="javascript:;"><span class="lxdz">'+data["content"].message.items[0].lxdh+'</span><img src="../../img/phone.png"/></a>'
    	    			 +'<p><label>商品描述：</label><span>'+spms+'</span></p>'
	    			 +'</div>'
	    			 +'<div class="shop_xj"><h5>'+data["content"].message.items[0].spmc+'</h5>'
	    			 	+'<div class="shop_price">'
    	    			+'<p><label>商品售价</label><span id="spjg" class="'+data["content"].message.items[0].spjg+'">￥'+data["content"].message.items[0].spjg+'</span></p>'
    	    			+'<p><label>商品类型</label><span>'+data["content"].message.items[0].flmc+'</span></p>'
	    			 +'</div>'
	    			 +'<button class="spxj">下架</button>'
	    			 +'<button class="spbj">编辑</button>'
   	    			 +'</div></div>';
   	    		}
       		  });
         $('.content').append(html);
         //商品编辑
         tzscSpbj(doms,_spzt,_spid,spmc,spms,src);
         //商品下架
         tzscSpxjXq(_spid,_spzt);
	 });
}

//商品下架
function tzscSpxjXq(_spid,_spzt){
	$('.spxj').click(function(){
		$.ajaxSettings.async=false;
		$.getJSON('/WDDXSERVER/bsdt/tzsc_Spxj.action?userid='+user_id+'&ticket='+ticket,
				{
			   	spbh:_spid,
			   	function_id:function_id,
				spzt:_spzt
				},
				function(data){});
	});
}

//修改商品
function tzscSpbj(dom,_spzt,_spid,spmc,spms,src){
	$('.spbj').click(function(){
		var lxdz=$('.shop_message a span.lxdz').text();
		var spjg=$('#spjg').attr('class');
		 var doms = $('.content').children().clone(true);
    	 $('.content').children().remove();
    	 $('a.back-reveal-modal').show(0);
    	 $('a.back-reveal-modal').unbind('click').click(function(){
    		$('div.office_tzsc_spfb').remove();
    		$('.content').append(doms);
    		 $('a.back-reveal-modal').unbind('click').click(function(){
    	    		$(this).hide(0);
    	    		$('div.tzsc_shop_xj').remove();
    	    		$('.content').append(dom);
    	    		
    	    	 });
    	 });
    	 var html='';
			 html='<div class="office_tzsc_spfb">'
					 +'<p>商品名称</p><input type="text" class="spmc" value="'+spmc+'">'
					 +'<p>商品类型</p><select>'
						 +'<option class="splx" value="1">手机</option>'
						 +'<option value="2">摄像器材</option>'
						 +'<option value="3">数码游戏</option>'
						 +'<option value="4">电脑配件</option>'
						 +'<option value="5">女装</option>'
						 +'<option value="6">男装</option>'
						 +'<option value="7">鞋包/配饰</option>'
						 +'<option value="8">香水/美容</option>'
						 +'<option value="9">书籍/影音</option>'
						 +'<option value="10">食品/水果</option>'
						 +'<option value="11">体育用品</option>'
						 +'<option value="12">其他</option>'
					 +'</select>'
					 +'<p>商品状态</p><select>'
						 +'<option class="spzt" value="1">正常</option>'
						 +'<option  value="2">缺货</option>'
						 +'<option  value="3">打折</option>'
						 +'<option  value="4">热卖</option>'
						 +'<option  value="5">推荐</option>'
					 +'</select>'
					 +'<p>商品价格</p><input type="text" class="spjg" value="'+spjg+'">'
					 +'<p>联系电话</p><input type="text" placeholder="请输入联系电话（只允许数字）" value="'+lxdz+'" maxlength="11">'
					 +'<p>商品描述</p><textarea  placeholder="请输入商品描述" class="spms">'+spms+'</textarea>'
					 +'<p>照片</p>'
					 +'<div class="imgs" id="addimgs">'
					 	+'<form class="upload" id="fileForm" method="post" action="/FS/loadpic/loadpicsform.action?" name="fileForm1" enctype="multipart/form-data" >'
						+'<img src="'+src+'" id="xmTanImg" class="xmTanImg"/><p>添加照片</p>'
					 	+'<input type="file" name="file" class="upload_img" id="tascUploadImg" onchange="xmTanUploadImg(this)"/>'
					 +'</form></div>'
			         +'<div id="xmTanDiv"></div>'
			         +'<iframe name="uploadFrame" id="uploadFrame" style="display:none;"></iframe>'
					 +'<input class="submit" type="button" value="提交">'
				 +'</div>';
		
		 $('.content').append(html);
		 upLoadImgs(_spid);
	});
}
//跳蚤市场-发布商品信息
function upLoadImgs(_spid){
	 $('.submit').click(function(){
		 addDataXg(_spid);
	 });
}

function addDataXg(_spid){
	 var _spmc=$('.spmc').val();
	 var _splx=$('.splx').val();
//	 var _splx=$('.splx option:selected').val();
	 var _spjg=$('.spjg').val();
	 var _spms=$('.spms').val();
	 var _spzt=$('.spzt').val();
//	 var _spzt=$('.spzt option:selected').val();
	 $.ajax({
		 url:'/WDDXSERVER/bsdt/tzsc_Xgsp.action?userid='+user_id+'&ticket='+ticket,
	    	type:'get',
	    	data:{
	    		function_id:function_id,
	    		spmc:_spmc,
	    		splx:_splx,
	    		spjg:_spjg,
	    		spms:_spms,
	    		spzt:_spzt,
	    		spbh:_spid,
	    		pics:_fjlb.join()
	    	},
	    	dataType:'json',
	    	success:function(data){}
	 });
}

//跳蚤市场-搜索商品
function tzscDzsplb(){
	 $('.Dzsplb').click(function(){        
		var _spmc=$('.spmcSs').val();
		var px='k';
		var doms = $('.content').children().clone(true);
    	$('.content').children().remove();
    	$('a.back-reveal-modal').show(0);
    	$('a.back-reveal-modal').unbind('click').click(function(){
    		$(this).hide(0);
    		$('div.office_phone').remove();
    		$('.content').append(doms);
    	});
		 var html='<div class="office_phone"><div class="office_fun_title"><ul>'
			 	+'<li class="a_active"><a href="javascript:;" class="k">最新</a></li>'
			 	+'<li><a href="javascript:;" class="j">价格由高到低</a></li>'
			 	+'<li><a href="javascript:;" class="s">价格由低到高</a></li></ul></div>'
			 	+'<div class="office_fun_info"><ul>';
		$.ajaxSettings.async=false;
		$.getJSON('/WDDXSERVER/bsdt/tzsc_Dzsplb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&pagenow=1',
			  {
			function_id:function_id,
			spmc:_spmc,
			px:px
			  },
			  function(data){
				  if(!(data["content"].message.items==0||data["content"].message.items==null)){
			 		 $.each(data["content"].message.items,function(i,r){
							html+='<li class="'+r["spid"]+'">'
							+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
			 		 });
				  }
			  });
		html+='</ul></div>'
			+'<div class="pagechange"><ul>'
			+'<li class="nextpage"><a href="javascript:;">下一页></a></li>'
			+'<li class="index"><a href="javascript:;">首页</a></li>'
			+'<li class="previouspage"><a href="javascript:;"><上一页</a></li>'
			+'</ul></div>'
			+'</div>';
		$('.content').append(html);
		tzscSpxq(doms);
		sslbPx(_spmc,doms);
		fySslb(_spmc,doms,px);
	 }); 
}
//搜索列表排序
function sslbPx(_spmc,doms){
	 $('.office_fun_title ul li a').click(function(){
		 var px=$(this).attr('class');
		 var html='<div class="office_fun_info"><ul>';
		$.ajaxSettings.async=false;
		$.getJSON('/WDDXSERVER/bsdt/tzsc_Dzsplb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3&pagenow=1',
			  {
				function_id:function_id,
		 		px:px,
		 		spmc:_spmc
			  },
			  function(data){
				  if(!(data["content"].message.items==0||data["content"].message.items==null)){
			 		 $.each(data["content"].message.items,function(i,r){
							html+='<li class="'+r["spid"]+'">'
							+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
			 		 });
				  }
			  });
		html+='</ul></div>';
		$('.office_fun_info').empty().append(html);
		tzscSpxq(doms);
		fySslb(_spmc,doms,px);
	 });
}
function fySslb(_spmc,doms,px){
	 var pageNum=1;
	 $('.pagechange ul li').unbind('click').click(function(){
		 var className=$(this).attr("class");
			 if(className=='nextpage'){
				 pageNum+=1;
				 pageSslb(_spmc,pageNum,doms,px);
				 return;
			 }else if(className=='previouspage'){
				 pageNum-=1;
				 if(pageNum==0){pageNum=1;}
				 pageSslb(_spmc,pageNum,doms,px);
			 }else{
				 pageNum=1;
				 pageSslb(_spmc,pageNum,doms,px);
			 }
});
}
function pageSslb(_spmc,pageNum,doms,px){
   	 var html='<div class="office_fun_info"><ul>';
	$.ajaxSettings.async=false;
	$.getJSON('/WDDXSERVER/bsdt/tzsc_Dzsplb.action?userid='+user_id+'&ticket='+ticket+'&pageSize=3',
		  {
			function_id:function_id,
			pagenow:pageNum,
	 		spmc:_spmc,
	 		px:px
		  },
		  function(data){
			  if(!(data["content"].message.items==0||data["content"].message.items==null)){
		 		 $.each(data["content"].message.items,function(i,r){
						html+='<li class="'+r["spid"]+'" id="'+r["flid"]+'">'
						+'<a href="javascript:;"><div><img src="'+r["fjdz"]+'" /></div><span>￥'+r["spjg"]+'</span><p>'+r["spmc"]+'</p></a></li>';
		 		 });
			  }
		  });
	html+='</ul></div>'
		+'</div>';
	$('.office_fun_info').empty().append(html);
	tzscSpxq(doms);
}
